import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'

export default createStore({
  state: {
    isGetterRouter: false,
    iscollapsed: false,
    userInfo: {}
  },
  getters: {
  },
  mutations: {
    changeGetRouter(state, value) {
      state.isGetterRouter = value
    },
    changeCollapse(state) {
      state.iscollapsed = !state.iscollapsed
    },
    changeUserInfo(state, value) {
      state.userInfo = {
        ...state.userInfo,
        ...value
      }
    },
    clearUserInfo(state) {
      state.userInfo = {}
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [createPersistedState({
    paths: ['iscollapsed', 'userInfo']   //控制是否持久化
  })]
})
